Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
Sanitize path in file_open against suffix
Browse files Browse the repository at this point in the history
issue6361
review33191002
  • Loading branch information
cedk committed Apr 3, 2017
1 parent 798f842 commit 30e9785
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
@@ -1,3 +1,4 @@
* Sanitize path in file_open against suffix (CVE-2017-0360)
* Add constraint on user password
* Remove Property field
* Add MultiValueMixin and ValueMixin
Expand Down
5 changes: 5 additions & 0 deletions trytond/tests/test_tools.py
Expand Up @@ -134,6 +134,11 @@ def test_file_open(self):
with self.assertRaisesRegexp(IOError, "Permission denied:"):
file_open('../../foo')

def test_file_open_suffix(self):
"Test file_open from same root name but with a suffix"
with self.assertRaisesRegexp(IOError, "Permission denied:"):
file_open('../trytond_suffix', subdir=None)


def suite():
func = unittest.TestLoader().loadTestsFromTestCase
Expand Down
2 changes: 1 addition & 1 deletion trytond/tools/misc.py
Expand Up @@ -32,7 +32,7 @@ def secure_join(root, *paths):
"Join paths and ensure it still below root"
path = os.path.join(root, *paths)
path = os.path.normpath(path)
if not path.startswith(root):
if not path.startswith(os.path.join(root, '')):
raise IOError("Permission denied: %s" % name)
return path

Expand Down

0 comments on commit 30e9785

Please sign in to comment.